//
//  MLWMenuTableViewCell.m
//  KITCHEN_STORIES
//
//  Created by 孟令通 on 16/6/13.
//  Copyright © 2016年 MLW. All rights reserved.
//

#import "MLWMenuTableViewCell.h"
#import "UIImageView+WebCache.h"
#import "MLWSecondModel.h"
#import <MJRefresh.h>

@implementation MLWMenuTableViewCell

- (void)dealloc
{
    [_leftImageView release];
    [_centerLabel release];
    [_titleLabel release];
    [_likeLabel release];
    [_collectLabel release];
    [_dataModel release];
    [super dealloc];
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        self.leftImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, ScreenWidth / 3, ScreenHeight / 6)];
        self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.leftImageView.frame.origin.x + self.leftImageView.frame.size.width + 10, self.leftImageView.frame.origin.y + 2, ScreenWidth - (self.leftImageView.frame.origin.x + self.leftImageView.frame.size.width + 10), 30)];
        self.centerLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.titleLabel.frame.origin.x, self.titleLabel.frame.origin.y + self.titleLabel.frame.size.height + 2, self.titleLabel.frame.size.width, 50)];
        self.likeLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.centerLabel.frame.origin.x, self.centerLabel.frame.origin.y + self.centerLabel.frame.size.height + 2, ScreenWidth / 4, 30)];
        self.collectLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.likeLabel.frame.origin.x + self.likeLabel.frame.size.width + 20, self.likeLabel.frame.origin.y, self.likeLabel.frame.size.width, self.likeLabel.frame.size.height)];
        
        [self.contentView addSubview:self.leftImageView];
        [self.contentView addSubview:self.titleLabel];
        [self.contentView addSubview:self.centerLabel];
        [self.contentView addSubview:self.likeLabel];
        [self.contentView addSubview:self.collectLabel];
        
        [_leftImageView release];
        [_titleLabel release];
        [_centerLabel release];
        [_likeLabel release];
        [_collectLabel release];
        
        
    }
    
    
    
    return self;
}

//重写model的set方法:

- (void)setDataModel:(MLWSecondModel *)dataModel
{
    if (_dataModel != dataModel) {
        [_dataModel release];
        _dataModel = [dataModel retain];
    }
    
    
    [self.leftImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://pic.ecook.cn/web/%@.jpg",dataModel.imageid]] placeholderImage:[UIImage imageNamed:@"placeholder"]];
    
    self.titleLabel.text = dataModel.name;
    
    self.centerLabel.text = dataModel.descript;
    
    self.centerLabel.numberOfLines = 0;
    //self.centerLabel.textColor = [UIColor blueColor];
    self.centerLabel.font = [UIFont systemFontOfSize:14];
    
    self.likeLabel.text = [NSString stringWithFormat:@"喜欢 %ld", dataModel.likeCount];
    
    self.collectLabel.text = [NSString stringWithFormat:@"收藏 %ld", dataModel.collectCount];
    
    
    
    
    
}




- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}


@end
